#define _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include <iostream>
#include <assert.h>
//#include <math.h>
#include <string.h>

using namespace std;

namespace _WX
{
	class string
	{

	public:
		string(const char* str = "");
		string(const string& s1);
		~string();
		typedef char* iterator;
		typedef const char* const_iterator;

		iterator begin()
		{
			return _str;
		}

		iterator end()
		{
			return _str + _size;
		}

		const_iterator begin() const
		{
			return _str;
		}

		const_iterator end() const
		{
			return _str + _size;
		}

		char*& c_str()
		{
			return _str;
		}
		void reserve(size_t n);
		void push_back(char ch);
		void append(const char* str);
		void insert(size_t pos, size_t n, char ch);
		void insert(size_t pos, const char* str);
		void clear();
		void erase(size_t pos = 0, size_t n = npos);
		size_t find(char ch, size_t pos = 0);
		size_t find(const char* str, size_t pos = 0);
		istream& getline(istream& in, string& s, char delim);

		size_t size()
		{
			return _size;
		}

		size_t size()
		{
			return _capacity;
		}

		char& operator[](size_t pos)
		{
			assert(pos < _size);
			return _str[pos];
		}

		const char& operator[](size_t pos)const
		{

			assert(pos < _size);
			return _str[pos];
		}

		string& operator=(const string& s);
		string& operator+=(char ch);
		string& operator+=(const char* str);

	private:
		char* _str;
		size_t _size;
		size_t _capacity;
		const static size_t npos;
	};
	ostream& operator<<(ostream& out, const string& s);
	istream& operator>>(istream& in, string& s);
}

void test1();
